﻿[
{
    "name": "Message Box",
    "desc": "Represents a dialog box that can be used to ask your user simple questions. The dialog box has a command bar that can support up to three commands. If you don't specify any commands, then a default command is added to close the dialog.",
    "source": function () {
        var messageDialog = new Windows.UI.Popups.MessageDialog("This is a simple pop up message box displayed", "Trial Tool");
        messageDialog.showAsync().then(function () {
            console.log("Message Box done");
        }, function () {
            console.error("Error with message box");
        });
    }
},
{
    "name": "Context Menu",
    "desc": "Represents a context menu.",
    "source": function () {
        var popupMenu = new Windows.UI.Popups.PopupMenu();
        var uiCommand = new Windows.UI.Popups.UICommand("Pop up menu command 1", function () {
            console.log("Clicked on Command 1");
        });
        popupMenu.commands.append(uiCommand);
        popupMenu.showAsync({ x: 100, y: 100 }).then(function () {
            console.log("Pop UP  Box done");
        }, function () {
            console.error("Error with context menu");
        });
    }
},
{
    "name": "Toast Notifier",
    "desc": "Raises a toast notification to the specific app that the notifier is bound to. This class also lets you schedule and remove toast notifications.",
    "source": function () {
        var toastNotificationManager = Windows.UI.Notifications.ToastNotificationManager;
        var toastNotifier = toastNotificationManager.createToastNotifier();
        var xmlDocument = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(Windows.UI.Notifications.ToastTemplateType.toastText01);
        xmlDocument.getElementsByTagName("text")[0].appendChild(xmlDocument.createTextNode("Notification text"));

        var toastNotification = Windows.UI.Notifications.ToastNotification(xmlDocument);
        toastNotification.onactivated = function () {
            console.log("Toast Shown");
        }
        toastNotification.onfailed = function () {
            console.error("Toast Failed");
        }
        toastNotifier.show(toastNotification);
    }
},
{
    "name": "Badge Updater",
    "desc": "Updates the badge of the application",
    "source": function () {
        var updateManager = Windows.UI.Notifications.BadgeUpdateManager;
        var updater = updateManager.createBadgeUpdaterForApplication()
        var notification = new updateManager.getTemplateContent(Windows.UI.Notifications.BadgeTemplateType.badgeNumber);
        notification.getElementsByTagName("badge")[0].attributes[0].value = "42";
        try {
            updater.update(notification);
        }
        catch (e) {
            console.error(e.toString());
        }
    }
},
{
    "name": "Tile Updater",
    "desc": "Updates the tile of the application",
    "source": function () {
        var updateManager = Windows.UI.Notifications.TileUpdateManager;
        var updater = updateManager.createTileUpdaterForApplication();
        var notification = new updateManager.getTemplateContent(Windows.UI.Notifications.TileTemplateType.tileWideText01);
        notification.getElementsByTagName("text")[0].appendChild(notification.createTextNode("axe"));
        try {
            updater.update(notification);
        }
        catch (e) {
            console.log(e.toString());
        }

    }
}
]